﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Stopwatch.Controls
{
    public partial class StopwatchControl : UserControl
    {
        public StopwatchControl()
        {
            InitializeComponent();
        }

        public bool IsShowPauseTag
        {
            get { return pauseTag.Visibility == System.Windows.Visibility.Visible; }
            set
            {
                pauseTag.Visibility = (value ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed);
            }
        }

        public int Hours
        {
            get
            {
                return Int32.Parse(hours.Text);
            }
            set
            {
                if (value > 0)
                {
                    hoursArea.Visibility = System.Windows.Visibility.Visible;
                }
                else if (hoursArea.Visibility == System.Windows.Visibility.Visible)
                {
                    hoursArea.Visibility = System.Windows.Visibility.Collapsed;
                }

                hours.Text = value.ToString();
            }
        }

        public int Minutes
        {
            get
            {
                return Int32.Parse(minutes.Text);
            }
            set
            {
                minutes.Text = value.ToString("D2");
            }
        }

        public int Seconds
        {
            get
            {
                return Int32.Parse(seconds.Text);
            }
            set
            {
                seconds.Text = value.ToString("D2");
            }
        }

        public int Milliseconds
        {
            get
            {
                return Int32.Parse(milliseconds.Text);
            }
            set
            {
                milliseconds.Text = value.ToString("D2");
            }
        }

        public int SubMinutes
        {
            get
            {
                return Int32.Parse(subMinutes.Text);
            }
            set
            {
                subMinutes.Text = value.ToString("D2");
            }
        }

        public int SubSeconds
        {
            get
            {
                return Int32.Parse(subSeconds.Text);
            }
            set
            {
                subSeconds.Text = value.ToString("D2");
            }
        }

        public int SubMilliseconds
        {
            get
            {
                return Int32.Parse(subMilliseconds.Text);
            }
            set
            {
                subMilliseconds.Text = value.ToString("D2");
            }
        }

        bool subEnabled;

        public bool SubEnabled
        {
            get
            {
                return subEnabled;
            }
            set
            {
                subEnabled = value;

                if (subEnabled)
                {
                    subTimer.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    subTimer.Visibility = System.Windows.Visibility.Collapsed;
                }
            }
        }
    }
}
